package com.kuzan.autocloud.common.model.form;

import com.kuzan.autocloud.common.SelectItems;
import com.kuzan.autocloud.common.model.Base;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * <p>Description: </p>
 *
 * @author kuzank
 */
@Data
@NoArgsConstructor
@Entity
@Table(name = "sys_form")
public class Form extends Base {

    @Column
    private String collection;
    @Column(length = 32)
    private String databaseType;
    @Column(length = 32)
    private String groupobj;
    /**
     * 启用自定义编码
     */
    @Column(columnDefinition = "bit(1) default 0")
    private boolean enableautocode = false;
    /**
     * 总计大小
     */
    @Column(columnDefinition = "INT default 0")
    private int total = 0;


    public static Form of(String title, String collection, String formid) {
        Form _obj = new Form();
        _obj.setTitle(title);
        _obj.setCollection(collection);
        _obj.setId(formid);
        _obj.setGroupobj(SelectItems.SystemGrup.System.value());
        _obj.setSort(getSortIncrement());
        return _obj;
    }


    public enum FormDatabseType {

        pid("formDatabseType"),

        Form("fdbt_form"),
        View("fdbt_view");

        private String name;

        FormDatabseType(String name) {
            this.name = name;
        }

        public String value() {
            return name;
        }

        public String getName() {
            return name;
        }
    }
}
